package router

import (
	"chat/docs"
	"chat/service"
	"chat/utils"

	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func Router() *gin.Engine {
	r := gin.Default()

	r.Use(utils.AuthMiddleware)

	docs.SwaggerInfo.BasePath = ""
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	r.GET("/user/get-verification-code", service.GetVerificationCode)
	r.GET("/user/new-friends-or-groups", service.GetNewFriendOrGroups)
	r.GET("/user/history", service.GetHistoryList)
	r.POST("/user/login", service.Login)
	r.POST("/user/logout", service.Logout)
	r.POST("/user/register", service.Register)
	r.POST("/user/apply-friend", service.ApplyFriend)
	r.GET("/user/new-friend-apply", service.NewFirendApply)
	r.POST("/user/agree-new-friend", service.AgreeNewApply)
	r.GET("/user/friend-list", service.GetFriendList)
	r.GET("/user/read-msg", service.ReadMessage)
	r.GET("/user/has-on-line", service.HasOnLine)
	r.POST("/user/edit-profile", service.EditProfile)

	r.POST("/group/create", service.CreateGroup)
	r.GET("/group/users", service.GetGroupUsers)
	r.GET("/group/notice-list", service.GetNotices)
	r.POST("/group/notice-add", service.AddNotice)
	r.GET("/group/notice-del", service.DelNotice)
	r.GET("/group/dissolve", service.DissolveGroup)
	r.POST("/group/invitation", service.InvitationUserToGroup)
	r.POST("/group/move-user", service.MoveUserOnGroup)

	//WEBSOCKET
	r.GET("/user/chat", service.SendUserMsg)
	r.GET("/user/test", service.SendMsg)
	r.POST("/attach/send-file", service.UploadFile)

	// UPLOAD file
	r.POST("/attach/avatar", service.UploadAvatar)
	r.GET("/attach/emoji-list", service.EmojiList)
	r.GET("/attach/download", service.DownloadFile)

	return r
}
